package com.example.myapplication.mainactivity

import android.view.View
import com.blankj.utilcode.util.ToastUtils
import com.example.myapplication.R
import com.example.myapplication.base.BaseActivity
import com.example.myapplication.ben.MainTabModel
import com.example.myapplication.model.CallBack
import com.example.myapplication.model.CommentModel
import com.example.myapplication.permission.PermissionsManager
import com.example.myapplication.permission.PermissionsResultAction
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : BaseActivity() {

    override fun initViews() {
        super.initViews()
        val readAndWriteArray = arrayOf("android.permission.READ_PHONE_STATE")
        PermissionsManager.getInstance()
            .requestPermissionsIfNecessaryForResult(this, readAndWriteArray,
                object : PermissionsResultAction() {
                    override fun onGranted() {

                    }

                    override fun onDenied(permission: String?) {
                    }
                })
        CommentModel.getInstant().getcatalist(object : CallBack<MainTabModel> {
            override fun onFailure(fail: String?) {
                ToastUtils.showShort(fail)
                findViewById<View>(R.id.refreshLayout).visibility = View.VISIBLE
            }


            override fun onSuccess(t: MainTabModel?, isSuccess: Boolean, msg: String) {
                refreshLayout.visibility = View.GONE
            }
        })
    }


    override fun createLayout(): Int {
        return R.layout.activity_main
    }

}